﻿@model IEnumerable<BOL.tbl_Url>

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>URLs On LinkHub</h2>
<div class="pull-right">
    <div class="btn-group ">
        <button type="button" class="btn btn-primary">Export To</button>
        <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></button>
        <ul class="dropdown-menu">
            <li>@Html.ActionLink("Excel", "ExportTo", new { ReportType = "Excel" })</li>
            <li>@Html.ActionLink("PDF", "ExportTo", new { ReportType = "PDF" })</li>
            <li>@Html.ActionLink("Word", "ExportTo", new { ReportType = "Word" })</li>
        </ul>
    </div>
</div>
<table class="table table-responsive table-bordered table-striped table-hover">

    <tr class="info">
        <th>
            @Html.ActionLink("UrlTitle", "Index", new { SortOrder = (ViewBag.SortOrder == null ? "Asc" : (ViewBag.SortOrder == "Asc" ? "Desc" : "Asc")), SortBy = "Title", page = (ViewBag.Page == null ? "1" : ViewBag.Page) })
        </th>
        <th>
            @Html.ActionLink("Url", "Index", new { SortOrder = (ViewBag.SortOrder == null ? "Asc" : (ViewBag.SortOrder == "Asc" ? "Desc" : "Asc")), SortBy = "Url", page = (ViewBag.Page == null ? "1" : ViewBag.Page) })
        </th>
        <th>
            @Html.ActionLink("urlDesc", "Index", new { SortOrder = (ViewBag.SortOrder == null ? "Asc" : (ViewBag.SortOrder == "Asc" ? "Desc" : "Asc")), SortBy = "UrlDesc", page = (ViewBag.Page == null ? "1" : ViewBag.Page) })
        </th>
        <th>
            @Html.ActionLink("CategoryName", "Index", new { SortOrder = (ViewBag.SortOrder == null ? "Asc" : (ViewBag.SortOrder == "Asc" ? "Desc" : "Asc")), SortBy = "Category", page = (ViewBag.Page == null ? "1" : ViewBag.Page) })
        </th>

    </tr>

    @foreach (var item in Model)
    {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.UrlTitle)
            </td>
            <td>
                <a target="_blank" href=@item.Url>@item.Url</a>
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.UrlDesc)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.tbl_Category.CategoryName)
            </td>

        </tr>
    }

</table>
@{
    double TotalPage = @ViewBag.TotalPages;
}

<ul class="pagination">
    @for (int i = 1; i <= TotalPage; i++)
    {

        if (i == ViewBag.Page)
        {
            <li class="active"> @Html.ActionLink(i.ToString() + " ", "Index", new { SortOrder = (ViewBag.SortOrder == null ? "Asc" : ViewBag.SortOrder), SortBy = (ViewBag.SortBy == null ? "Title" : ViewBag.SortBy), Page = i })</li>
        }
        else
        {
            <li>
                @Html.ActionLink(i.ToString() + " ", "Index", new { SortOrder = (ViewBag.SortOrder == null ? "Asc" : ViewBag.SortOrder), SortBy = (ViewBag.SortBy == null ? "Title" : ViewBag.SortBy), Page = i })
            </li>
        }

    }
</ul>